package com.example.jjc.rxjava_retrofit2_demo;

import android.app.AlertDialog;
import android.app.Fragment;
import android.widget.Toast;

import butterknife.OnClick;
import rx.Subscription;

/**
 * Created by Administrator on 2017/3/15.
 */

public class BaseFragment extends Fragment {
    protected Subscription subscription;
    public static String FRA_TAG_1;
//    @OnClick(R.id.tip_btn)
//    void tip(){
//        new AlertDialog.Builder(getActivity())
//                .setTitle(getTitleRes())
//                .setView(getActivity().getLayoutInflater().inflate(getDialogRes(),null))
//                .show();
//    }

    /**
     * 获取标题资源
     * @return
     */
//    protected abstract int getTitleRes();

    /**
     * 获取弹出框视图资源
     * @return
     */
//    protected abstract int getDialogRes();

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unSubscription();
    }

    /**
     * 取消订阅
     */
    protected void unSubscription(){
        if (subscription != null && !subscription.isUnsubscribed()){
            subscription.unsubscribe();
        }
    }

    public void showToast(String msg){
        Toast.makeText(getActivity(),msg,Toast.LENGTH_SHORT).show();
    }


}
